package com.qiaoyanqing.textdemoqyq7.Activities;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.qiaoyanqing.textdemoqyq7.R;

public class WelconmeActivity extends AppCompatActivity {
    private SharedPreferences mPreferences;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welconme);
        mPreferences=getSharedPreferences("app_first", Context.MODE_PRIVATE);
        new SleepThread().start();

    }
    private class SleepThread extends Thread {

        @Override
        public void run() {
            super.run();
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Intent intent=new Intent();
            boolean isFirst=mPreferences.getBoolean("first",true);
        if(isFirst){
            intent.setClass(WelconmeActivity.this,FirstActivity.class);
            SharedPreferences.Editor editor=mPreferences.edit();
            editor.putBoolean("first",false);
            editor.commit();
        }else {
            intent.setClass(WelconmeActivity.this,MainActivity.class);
        }
            startActivity(intent);
            finish();
        }
    }
}
